import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;

import java.util.Calendar;
import javax.swing.Timer;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;

public class MainScreen extends JPanel{
	private static final long serialVersionUID = 1L;
	
	private  ImageIcon logI = new ImageIcon(this.getClass().getResource("images/login.png"));
	private  ImageIcon tIn = new ImageIcon(this.getClass().getResource("images/timein.png"));
	private  ImageIcon tOut = new ImageIcon(this.getClass().getResource("images/timeout.png"));
	private  ImageIcon logIr = new ImageIcon(this.getClass().getResource("images/login1.png"));
	private  ImageIcon tInr = new ImageIcon(this.getClass().getResource("images/timein1.png"));
	private  ImageIcon tOutr = new ImageIcon(this.getClass().getResource("images/timeout1.png"));
	JButton logIn, timeIn, timeOut;
	int goFunc=0;
	JLabel curDateTime;
	
	public MainScreen()
	{
		logIn = new JButton(logI);
		timeIn = new JButton(tIn);
		timeOut = new JButton(tOut);
		curDateTime = new JLabel();
		
		setLayout(null);
		
		curDateTime.setBounds(25, 560, 300, 25);
		logIn.setBounds(300, 230, 200, 55); //original place x=220
		timeIn.setBounds(300, 310, 200, 55);
		timeOut.setBounds(300, 390, 200, 55);
		
		logIn.setBorderPainted(false);
		timeIn.setBorderPainted(false);
		timeOut.setBorderPainted(false);
		
		logIn.setRolloverIcon(logIr);
		logIn.setRolloverEnabled(true);
		timeIn.setRolloverIcon(tInr);
		timeIn.setRolloverEnabled(true);
		timeOut.setRolloverIcon(tOutr);
		timeOut.setRolloverEnabled(true);
		
		logIn.setContentAreaFilled(false);
		timeIn.setContentAreaFilled(false);
		timeOut.setContentAreaFilled(false);
		
		curDateTime.setForeground(Color.WHITE);
		curDateTime.setFont(new Font("sansserif", Font.BOLD, 12));
		
		setOpaque(false);
		add(logIn);
		add(timeIn);
		add(timeOut);
		add(curDateTime);
		//add(eXit);
		
		curDateTime.setText(now("MMMM dd, yyyy h:mm:ss a"));
		
		setSize(806,628);
		setVisible(true);
		
		Timer timer = new Timer(1000, new MyClockActionListener());
		timer.start();
		
		
		logIn.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			goFunc = 1;
    			MainPanel.goToPage(1);
    		}
    		});
		
		timeIn.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			goFunc = 2;
    			MainPanel.goToPage(1);
    		}
    		});
		timeOut.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			goFunc = 3;
    			MainPanel.goToPage(1);
    		}
    		});
		
		/*
		eXit.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				sMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			}
		});
		*/
		
		
	}
	
	public int getFunc(){
		return goFunc;
	}
	
	class MyClockActionListener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			 curDateTime.setText(now("MMMMM dd, yyyy h:mm:ss a"));
		}
	}
	
	public static String now (String dateFormat){
		
		Calendar cal = Calendar.getInstance();
	    SimpleDateFormat dateTime = new SimpleDateFormat(dateFormat);
	    return dateTime.format(cal.getTime());
	}
	

}
